//
//  NomalImageTableViewCell.m
//  VEW
//
//  Created by lanou3g on 15/7/22.
//  Copyright (c) 2015年 Y团. All rights reserved.
//

#import "NomalImageTableViewCell.h"

@implementation NomalImageTableViewCell

// 初始化cell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}

 -(void)setupView
{
  
    //图片布局
    
    self.picImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10,(CGRectGetWidth([[UIScreen mainScreen]bounds]))/3,(CGRectGetWidth([[UIScreen mainScreen]bounds]))/3)];
    self.picImageView.layer.cornerRadius = 5;
    self.picImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.picImageView];
    
    //题目布局
    self.titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.picImageView.frame)+20, 10,(CGRectGetWidth([[UIScreen mainScreen]bounds]))*(2/3), 50)];
    self.titleLabel.textAlignment=NSTextAlignmentJustified;
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font=[UIFont fontWithName:@"Helvetica-Bold" size:16];
    [self.contentView addSubview:self.titleLabel];
    
    
    //发布时间
    self.timeLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.picImageView.frame)+20,CGRectGetWidth(self.picImageView.frame)-6, CGRectGetWidth(self.picImageView.frame)+50, 16)];
    self.timeLabel.font=[UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.timeLabel];

    //评论
    self.commentLabel = [[UILabel alloc]initWithFrame:CGRectMake((CGRectGetWidth([[UIScreen mainScreen]bounds]))*(2/3)+20, CGRectGetWidth(self.picImageView.frame)-6,(CGRectGetWidth([[UIScreen mainScreen]bounds]))/3-30 , 16)];
    self.timeLabel.font=[UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.commentLabel];

}


// 定义一个计算字符串高度的方法
+(CGFloat)stringHeight:(NSString *)string {
    // 设置字符串的属性
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:16]};
    // 计算字符串的区域
    CGRect rect = [string boundingRectWithSize:CGSizeMake(200, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size.height;
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
